package com.hnkywl.sts.entity.zjgl;

/**
 * Created by lw on 2015/11/10.
 */

import com.hnkywl.sts.entity.BaseEntity;
import com.hnkywl.sts.entity.htgl.Cght;
import com.hnkywl.sts.entity.htgl.Htmx;
import com.hnkywl.sts.entity.htgl.Xsht;
import com.hnkywl.sts.entity.organ.Gsjg;
import com.hnkywl.sts.entity.sys.Yg;
import com.hnkywl.sts.entity.xsgl.Xsmx;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import javax.persistence.*;

/**
 * 说明：现金优惠实体类
 * 包:  com.hnkywl.sts.entity.zjgl
 * 类描述:    现金优惠
 * 修改备注: [说明本次修改内容]
 * 版本:        [v1.0]
 */

@Entity
@Table(name = "T_BIZ_XJYH")
@Where(clause = "deleted!='1'")
public class Xjyh extends BaseEntity {
    @Id
    @SequenceGenerator(name = "seqXjyh", allocationSize = 1, sequenceName = "SEQ_BIZ_YHSX")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqXjyh")
    private Long id;

    /**
     * 备注
     */
    private String bz;

    /**
     * 优惠金额
     */
    private Double yhje;

    /**
     * 使用状态，0未使用，1已使用
     */
    private Integer syzt;

    /**
     * 采购合同
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CGHT_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Cght cght;

    /**
     * 客户
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "KH_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Gsjg kh;

    /**
     * 销售金额
     */
    @Formula("(select sum(t.HSJ) from T_BIZ_HTMX t where t.HT_ID=CGHT_ID and t.deleted!=1)")
    private Double xsje;

    /**
     * 操作人
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "YG_ID")
    private Yg czr;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getBz() {
        return bz;
    }

    public void setBz(String bz) {
        this.bz = bz;
    }

    public Double getYhje() {
        return yhje;
    }

    public void setYhje(Double yhje) {
        this.yhje = yhje;
    }

    public Integer getSyzt() {
        return syzt;
    }

    public void setSyzt(Integer syzt) {
        this.syzt = syzt;
    }

    public Gsjg getKh() {
        return kh;
    }

    public void setKh(Gsjg kh) {
        this.kh = kh;
    }

    public Yg getCzr() {
        return czr;
    }

    public void setCzr(Yg czr) {
        this.czr = czr;
    }

    public Cght getCght() {
        return cght;
    }

    public void setCght(Cght cght) {
        this.cght = cght;
    }

    public Double getXsje() {
        return xsje;
    }

    public void setXsje(Double xsje) {
        this.xsje = xsje;
    }
}
